home *** CD-ROM | disk | FTP | other *** search
- From: jv@mh.nl.UUCP (Johan Vromans)
- Newsgroups: comp.sources.misc
- Subject: v02i058: shstat - system status display (System V)
- Message-ID: <7241@ncoast.UUCP>
- Date: 18 Feb 88 02:34:23 GMT
- Approved: allbery@ncoast.UUCP
-
- Comp.sources.misc: Volume 2, Issue 58
- Submitted-By: "Johna Vromans" <jv@mh.nl>
- Archive-Name: shstat
-
- This is a little shell script which repeatedly displays the system
- status, leaving out uninteresting info. It is essentially a "ps -ef"
- post-processor. It can (and should) be tailored for your own system.
-
- It will probably be blown away by some nifty perl program in the near
- future, or by a program using some kind of "ptw" (process-tree-walk) function.
- Until then ... have fun.
-
- By the way - this is a X/OPEN (or System V) compliant script. There's
- enough BSD-only software in the world already.
-
- --
- Johan Vromans | jv@mh.nl via European backbone
- Multihouse N.V., Gouda, the Netherlands | uucp: ..{uunet!}mcvax!mh.nl!jv
- "It is better to light a candle than to curse the darkness"
-
- #-------------------------------- CUT HERE --------------------------------
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create:
- # shstat.sh
- # This archive created: Mon Feb 15 22:16:51 1988
- export PATH; PATH=/bin:/usr/bin:$PATH
- if test -f 'shstat.sh'
- then
- echo shar: "will not over-write existing file 'shstat.sh'"
- else
- cat << \SHAR_EOF > 'shstat.sh'
- #!/bin/sh
-
- # @(#)@ show_status 1.9 show system activity
- # @(#)@ Copyright 1988 by Johan Vromans - Multihouse Research
- # Contributed to Public Domain by the Author, Feb 15, 1988
-
- # This is a little shell script which repeatedly displays the current
- # system activity, filtering out unneeded entries.
- #
- # Display uses tty enhancements, if present.
- #
- # Usage: show_status [ sleep-value ]
-
- title="Multihouse USENET Gateway" # descriptive title of this system
-
- trap "rm -f /tmp/tmpa$$; trap '' 0; exit" 0 1 2 3 15
-
- # get display interval
- sleep="$1"
- if [ "$sleep" = "" ]
- then
- sleep=20
- fi
-
- # get terminal enhancements
- home=`tput home`
- home=${home:-`tput khome`}
- home=${home:-`tput clear`}
- clear=`tput ed`
- cln=`tput el`
- so=`tput smso`
- se=`tput rmso`
-
- # please keep the next line intact
- echo "$home`tput clear`show_status version 1.9 - Multihouse Research"
-
- # build top display line
- line=`ps -f | line | sed \
- -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" \
- -e "s/^\(.....................\).../\1/"`
- line="$so$line $se"
-
- # other relevant data
- pid=$$
- set `uname -a` # KEEP LAST - SCRIPT USES $1, $2 and so on ...
-
- # and here we go ... until interrupted
- while [ a = a ]
- do
- echo "$home$so $2 $1/$3 `date` $title $se$cln\n"
- # don't use a pipe - unwanted processes show up!
- ps -ef > /tmp/tmpa$$
- echo "$line"
- sort +1n -2 < /tmp/tmpa$$ | sed \
- -e "/ -sh/d" \
- -e "/ -csh/d" \
- -e "/ -ksh/d" \
- -e "1d" \
- -e "/ $pid /d" \
- -e "\./etc/getty.d" \
- -e "s/^\(.....................\).../\1/" \
- -e "s/\$/$cln/"
- echo "$clear\c"
-
- sleep $sleep
- done
- SHAR_EOF
- if test 1583 -ne "`wc -c < 'shstat.sh'`"
- then
- echo shar: "error transmitting 'shstat.sh'" '(should have been 1583 characters)'
- fi
- fi
- exit 0
- # End of shell archive
- --
- Johan Vromans | jv@mh.nl via European backbone
- Multihouse N.V., Gouda, the Netherlands | uucp: ..{uunet!}mcvax!mh.nl!jv
- "It is better to light a candle than to curse the darkness"
-